package com.xbongbong.saas.script.tempenum;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.enums.ComboTypeEnum;
import com.xbongbong.paas.enums.DateTimeEnum;
import com.xbongbong.paas.help.FormDataFormExplainHelper;
import com.xbongbong.paas.field.DefaultAttrPoJo;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.FormulaPoJo;
import com.xbongbong.paas.field.LimitChooseRangePoJo;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.paas.field.SerialNumberPoJo;
import com.xbongbong.pro.enums.AmountFlagEnum;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.pro.enums.SummaryTypeEnum;
import com.xbongbong.paas.field.SaasParticularAttributePoJo;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.enums.ForbiddenSettingEnum;
import com.xbongbong.saas.enums.OrderOutStockExpressStatusEnum;
import com.xbongbong.saas.enums.OutstockTypeEnum;
import com.xbongbong.saas.enums.RedundantTemplateTypeEnum;
import com.xbongbong.saas.enums.SelectProductEnum;
import com.xbongbong.saas.enums.SetTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.OrderOutStockEnum;
import com.xbongbong.saas.enums.business.OutstockEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import com.xbongbong.sys.enums.RoleEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 出库发货单
 *
 * @author wujian
 * @version v1.0
 * @date 2020/12/24
 * @since v1.0
 */
@Getter
public enum TempContractOutstockDistributorEnum {
    // 基本信息
    BASE_INFO(OrderOutStockEnum.BASE_INFO),
    SHEET_NO(OrderOutStockEnum.SHEET_NO),
    TIME(OrderOutStockEnum.TIME),
    LINK_DISTRIBUTOR(OrderOutStockEnum.LINK_DISTRIBUTOR),
    REF_ID(OrderOutStockEnum.REF_ID),
    WAREHOUSE_ID(OrderOutStockEnum.WAREHOUSE_ID),
    MANAGER_ID(OrderOutStockEnum.MANAGER_ID),
    EXPRESS_STATUS(OrderOutStockEnum.EXPRESS_STATUS),
    SHIP_DATE(OrderOutStockEnum.SHIP_DATE),
    PRODUCT_INFO(OrderOutStockEnum.PRODUCT_INFO),
    PRODUCT(OrderOutStockEnum.PRODUCT),
    // PRODUCT_TOTAL(OrderOutStockEnum.PRODUCT_TOTAL),
    TOTAL_MONEY(OrderOutStockEnum.TOTAL_MONEY),
    // 物流信息
    EXPRESS_INFO(OrderOutStockEnum.EXPRESS_INFO),
    EXPRESS_DATE(OrderOutStockEnum.EXPRESS_DATE),
    EXPRESS_NAME(OrderOutStockEnum.EXPRESS_NAME),
    EXPRESS_NO(OrderOutStockEnum.EXPRESS_NO),
    EXPRESS_MEMO(OrderOutStockEnum.EXPRESS_MEMO),
    MEMO(OrderOutStockEnum.MEMO),
    //收货信息
    RECEIPT_INFO(OrderOutStockEnum.RECEIPT_INFO),
//    RECEIPT_NAME(OrderOutStockEnum.RECEIPT_NAME),
    LINK_PARTNER_RECEIVER(OrderOutStockEnum.LINK_PARTNER_RECEIVER),
    RECEIPT_PHONE(OrderOutStockEnum.RECEIPT_PHONE),
    RECEIPT_ADDRESS(OrderOutStockEnum.RECEIPT_ADDRESS),
    //寄件信息
    SEND_INFO(OrderOutStockEnum.SEND_INFO),
    SEND_NAME(OrderOutStockEnum.SEND_NAME),
    SEND_PHONE(OrderOutStockEnum.SEND_PHONE),
    SEND_ADDRESS(OrderOutStockEnum.SEND_ADDRESS),
    // OUT_STOCK_AMOUNT(OrderOutStockEnum.OUT_STOCK_AMOUNT),

    //系统信息
    SYSTEM_INFO(OrderOutStockEnum.SYSTEM_INFO),
    CREATOR_ID(OrderOutStockEnum.CREATOR_ID),
    ADD_TIME(OrderOutStockEnum.ADD_TIME),
    UPDATE_TIME(OrderOutStockEnum.UPDATE_TIME),
    // 模板设计界面不需要展示的字段
    TYPE(OrderOutStockEnum.TYPE),
    OUTBOUND(OrderOutStockEnum.OUTBOUND),
    WAREHOUSE_ID_LINKED_TEXT(OrderOutStockEnum.WAREHOUSE_ID_LINKED_TEXT),
    REF_ID_LINKED_TEXT(OrderOutStockEnum.REF_ID_LINKED_TEXT),
    LINK_DISTRIBUATOR_HIDE(OrderOutStockEnum.LINK_DISTRIBUTOR_HIDE),
//    LINK_RECEIPT_HIDE(OrderOutStockEnum.LINK_RECEIPT_HIDE),
    LINK_PARTNER_RECEIVER_HIDE(OrderOutStockEnum.LINK_PARTNER_RECEIVER_HIDE),

    LINK_SEND_HIDE(OrderOutStockEnum.LINK_SEND_HIDE),

    // 优惠金额
    DISCOUNT_AMOUNT(OrderOutStockEnum.DISCOUNT_AMOUNT),

    ;
    private OrderOutStockEnum anEnum;

    TempContractOutstockDistributorEnum(OrderOutStockEnum outstockEnum) {
        this.anEnum = outstockEnum;
    }
    public static List<TempContractOutstockDistributorEnum> getAllEnum() {
        List<TempContractOutstockDistributorEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    // ===================================模板字段初始化======================================

    /**
     * 初始化编号
     * @param fieldAttrEntity
     */
    public static void initSheetNo(FieldAttrEntity fieldAttrEntity) {
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(SHEET_NO.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        // 不能重复
        fieldAttrEntity.setNoRepeat(1);
        // 默认的编号规则
        SerialNumberPoJo serialNumberPoJo = InitExplainsHelper.setSerialNumber(SerialNumberEnum.CONTRACT_OUTSTOCK_NO);
        fieldAttrEntity.setSerialNumber(serialNumberPoJo);
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 初始化出库类型
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initType(FieldAttrEntity fieldAttrEntity) {
        // 将出库类型设置为下拉选项
//        Map<Integer, String> outstockTypeMap = OutstockTypeEnum.getOutstockTypeMap();
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(OutstockTypeEnum.class, fieldAttrEntity.getFieldType()));
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 初始化发货状态
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initExpressStatus(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setItems(InitExplainsHelper.setCombItemByEnum(OrderOutStockExpressStatusEnum.class, fieldAttrEntity.getFieldType()));
        fieldAttrEntity.setRequired(1);
    }

    /**
     * 初始化日期
     *
     * @param fieldAttrEntity
     */
    public static void initTime(FieldAttrEntity fieldAttrEntity) {
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        defaultAttrPoJo.setDefaultType("today");
        fieldAttrEntity.setDateType(DateTimeEnum.TIME.getType());
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 初始化出库仓库
     * 将关联显示的字段设置到出库仓库字段中
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initWarehouseId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedText(OutstockEnum.WAREHOUSE_ID_LINKED_TEXT.getAttr());
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.WAREHOUSE.getCode());
        fieldAttrEntity.setIsForbidden(0);
    }

    /**
     * 初始化负责人字段
     * 将关联显示的字段设置到该字段中
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initManagerId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setMultiple(0);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setRequired(1);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setAdd(1);
        fieldAttrEntity.setAddAdvanceEnable(1);
        fieldAttrEntity.setShowAdd(1);
        fieldAttrEntity.setRemove(1);
        fieldAttrEntity.setRemoveAdvanceEnable(1);
        fieldAttrEntity.setShowRemove(1);
        // 默认的查询范围
        LimitChooseRangePoJo limitChooseRangePoJo = new LimitChooseRangePoJo();
        fieldAttrEntity.setLimitChooseRange(limitChooseRangePoJo);
        fieldAttrEntity.setAddRule(FormDataFormExplainHelper.getDefaultRule(RoleEnum.WAREHOUSE_MANAGER));
        fieldAttrEntity.setRemoveRule(FormDataFormExplainHelper.getDefaultRule(RoleEnum.WAREHOUSE_MANAGER));
    }

    /**
     * 初始化关联单据字段
     * 将关联显示的字段设置到该字段中
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initRefId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedText(OutstockEnum.REF_ID_LINKED_TEXT.getAttr());
        fieldAttrEntity.setLinkedType(XbbRefTypeEnum.CONTRACT.getCode());
        fieldAttrEntity.setIsMultiBusiness(1);
        fieldAttrEntity.setBusinessType(XbbRefTypeEnum.CONTRACT_OUTSTOCK.getCode());
        fieldAttrEntity.setIsForbidden(0);
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setRelyAttr(LINK_DISTRIBUTOR.anEnum.getAttr());
        saasParticularAttributePoJo.setRelyBusiness(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }


    /**
     * 物流单号
     */
    public static void initExpressNo(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setComboType(ComboTypeEnum.CUSTOM.getType());
        fieldAttrEntity.setDictionaryFlag(0);
        fieldAttrEntity.setIsDictionary(1);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setVisibleAdvancedForbidden(0);
        fieldAttrEntity.setSetType(SetTypeEnum.DISABLE_ALL.getCode());
        //不允许修改默认值
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setForbiddenSettingList(Collections.singletonList(ForbiddenSettingEnum.DISABLE_DEFAULT.getAlias()));
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setRequired(1);
    }

    public static void initCreatorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }

    public static void initAddTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initUpdateTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setUnableEditMemo(I18nMessageUtil.getMessage(StringConstant.AUTO_GEN_FIELD));
    }
    public static void initProducts(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }



    public static void initLinkDistributor(FieldAttrEntity fieldAttrEntity){
        fieldAttrEntity.setLinkedType(RedundantTemplateTypeEnum.CUSTOMER.getCode());
        fieldAttrEntity.setLinkedText(LINK_DISTRIBUATOR_HIDE.getAnEnum().getAttr());
        SaasParticularAttributePoJo saasParticularAttributePoJo = new SaasParticularAttributePoJo();
        saasParticularAttributePoJo.setMultiCheck(false);
        saasParticularAttributePoJo.setRelyMode("customer");
        saasParticularAttributePoJo.setRelyType("base");
        fieldAttrEntity.setSaasParticularAttributePoJo(saasParticularAttributePoJo);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    }

    // public static void initProductTotal(FieldAttrEntity fieldAttrEntity) {
    //     fieldAttrEntity.setAccuracy(2);
    //     fieldAttrEntity.setMemo("默认值为产品售价总计");
    //     fieldAttrEntity.setSummaryFlag(SummaryTypeEnum.SUM.getType());
    //     fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
    //     fieldAttrEntity.setEditable(0);
    //     DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
    //     FormulaPoJo formulaInfo = new FormulaPoJo();
    //     String formula = "SUM({self." + ContractEnum.PRODUCT.getAttr() + "." + SelectProductEnum.SUBTOTAL.getAttr() + "})";
    //     JSONObject labelMap = new JSONObject();
    //     labelMap.put("self." + ContractEnum.PRODUCT.getAttr() + "." + SelectProductEnum.SUBTOTAL.getAttr(), "关联产品.售价小计");
    //     formulaInfo.setFormula(formula);
    //     formulaInfo.setLabelMap(labelMap);
    //     defaultAttrPoJo.setDefaultType("formula");
    //     defaultAttrPoJo.setFormulaInfo(formulaInfo);
    //     fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
    //     // 合同金额默认限定 0 ~ 100000000000
    //     NumericalLimitsPoJo numericalLimits = new NumericalLimitsPoJo();
    //     numericalLimits.setMin(0D);
    //     numericalLimits.setMax(100000000000D);
    //     fieldAttrEntity.setNumericalLimits(numericalLimits);
    //     fieldAttrEntity.setNumericalLimitsFlag(1);
    // }

    public static void initTotalMoney(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(SummaryTypeEnum.SUM.getType());
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setMemo("默认值=产品明细中售价小计之和 - 优惠金额");
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        FormulaPoJo formulaInfo = new FormulaPoJo();
        String formula = "SUBTRACT(SUM({self." + OrderOutStockEnum.PRODUCT.getAttr() + "." + SelectProductEnum.SUBTOTAL.getAttr() + "}), self." + OrderOutStockEnum.DISCOUNT_AMOUNT.getAttr() + ")";
        JSONObject labelMap = new JSONObject();
        labelMap.put("self." + OrderOutStockEnum.PRODUCT.getAttr() + "." + SelectProductEnum.SUBTOTAL.getAttr(), "出库产品.售价小计");
        labelMap.put("self." + OrderOutStockEnum.DISCOUNT_AMOUNT.getAttr(), OrderOutStockEnum.DISCOUNT_AMOUNT.getAttrName());
        formulaInfo.setFormula(formula);
        formulaInfo.setLabelMap(labelMap);
        defaultAttrPoJo.setDefaultType("formula");
        defaultAttrPoJo.setFormulaInfo(formulaInfo);
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setNumAccuracyAndScopeHide(1);
    }

    public static void rollBackTotalMoney(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setSummaryFlag(SummaryTypeEnum.SUM.getType());
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setMemo("默认值=产品明细中售价小计之和");
        DefaultAttrPoJo defaultAttrPoJo = new DefaultAttrPoJo();
        FormulaPoJo formulaInfo = new FormulaPoJo();
        String formula = "SUM({self." + OrderOutStockEnum.PRODUCT.getAttr() + "." + SelectProductEnum.SUBTOTAL.getAttr() + "})";
        JSONObject labelMap = new JSONObject();
        labelMap.put("self." + OrderOutStockEnum.PRODUCT.getAttr() + "." + SelectProductEnum.SUBTOTAL.getAttr(), "出库产品.售价小计");
        formulaInfo.setFormula(formula);
        formulaInfo.setLabelMap(labelMap);
        defaultAttrPoJo.setDefaultType("formula");
        defaultAttrPoJo.setFormulaInfo(formulaInfo);
        fieldAttrEntity.setDefaultAttr(defaultAttrPoJo);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setNumAccuracyAndScopeHide(1);
    }



    public static void initReceiptPhone(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setRequired(0);
    }


    public static void initReceiptAddress(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setRequired(0);
    }
    public static void initSendPhone(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setRequired(0);
    }


    public static void initSendAddress(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setRequired(0);
    }

//    public static void initReceiptName(FieldAttrEntity fieldAttrEntity) {
//        fieldAttrEntity.setLinkedText(LINK_RECEIPT_HIDE.getAnEnum().getAttr());
//        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
//        fieldAttrEntity.setIsForbidden(0);
//        fieldAttrEntity.setRequired(1);
//    }
    public static void initLinkPartnerReceiver(FieldAttrEntity fieldAttrEntity) {
    fieldAttrEntity.setLinkedText(LINK_PARTNER_RECEIVER_HIDE.getAnEnum().getAttr());
    fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
    fieldAttrEntity.setIsForbidden(0);
    fieldAttrEntity.setRequired(1);
}

    public static void initSendName(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setLinkedText(LINK_SEND_HIDE.getAnEnum().getAttr());
        fieldAttrEntity.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setRequired(0);
        fieldAttrEntity.setEditable(1);
    }

    /**
     * 初始化发货日期
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initShipDate(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setRequired(1);
    }
    /**
     * 初始化物流公司
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initExpressName(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setVisibleAdvancedForbidden(0);
        fieldAttrEntity.setSetType(SetTypeEnum.DISABLE_ALL.getCode());
        //不允许修改默认值
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
//        fieldAttrEntity.setForbiddenSettingList(Collections.singletonList(ForbiddenSettingEnum.DISABLE_DEFAULT.getAlias()));
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setRequired(1);
    }

    /**
     * 初始化物流时间
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initExpressDate(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setEditForbidden(0);
        fieldAttrEntity.setVisibleAdvancedForbidden(0);
        fieldAttrEntity.setSetType(SetTypeEnum.DISABLE_ALL.getCode());
        //不允许修改默认值
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setForbiddenSettingList(Collections.singletonList(ForbiddenSettingEnum.DISABLE_DEFAULT.getAlias()));
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
        fieldAttrEntity.setRequired(1);
    }

    /**
     * 初始备注
     *
     * @param fieldAttrEntity
     * @author chaoxiong.lei
     * @Date 11:01 2019/1/18
     * @since
     **/
    public static void initExpressMemo(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setIsForbidden(0);
        fieldAttrEntity.setEditForbidden(0);
        fieldAttrEntity.setVisibleAdvancedForbidden(0);
        fieldAttrEntity.setSetType(SetTypeEnum.DISABLE_ALL.getCode());
        //不允许修改默认值
        fieldAttrEntity.setItemBanDefault(BasicConstant.ONE);
        fieldAttrEntity.setForbiddenSettingList(Collections.singletonList(ForbiddenSettingEnum.DISABLE_DEFAULT.getAlias()));
        fieldAttrEntity.setEditForbidden(BasicConstant.ZERO);
    }


    /**
     * 初始化优惠金额
     *
     * @param fieldAttrEntity 表单字段属性类
     */
    public static void initDiscountAmount(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setAccuracy(2);
        fieldAttrEntity.setSummaryFlag(SummaryTypeEnum.SUM.getType());
        fieldAttrEntity.setAmountFlag(AmountFlagEnum.YES.getType());
        fieldAttrEntity.setMemo("优惠金额=订货单中的优惠金额-已出库的优惠金额");
        fieldAttrEntity.setNumAccuracyAndScopeHide(0);
    }
}

